package main

/*
2020年2月17日23：11初步测试成功。经过了无数个小时的煎熬，!!!!!!!!!!!!
刘永和
*/

//"fmt"
//	"liuyh"
//	"strings"

//**********************************************

// func NewVar(name string) *Object {
// 	num := new(Object)
// 	num.Type = TypeTuple
// 	//num.Value = t
// }

/*****************************************************************/
type DrFuncCall struct {
	DrAbstractObject
	Name         string
	function     *DrFunction
	module       IObject
	Params       []*DrAbstractObject
	ParaNames    []string
	locals       map[string]IObject
	localClauses []*DrClause
	//result     *Object
	returnObject IObject
	clauseIndex  int
	executeIndex int
	baseClause   *DrClause
}

func (*DrFuncCall) Print() {

}

func (this *DrFuncCall) AddClause(funcName string, paraNames []*DrClause) int {
	clause := new(DrClause)
	clause.funcName = funcName
	clause.parameters = paraNames
	this.localClauses = append(this.localClauses, clause)
	return len(this.localClauses) - 1
}
func (this *DrFuncCall) GetLocalKeys() []string {
	var result []string
	for k, _ := range this.locals {
		result = append(result, k)
	}
	return result
}

//*****************************************************************/
type CallStack struct {
	slice []*DrFuncCall
}

func NewCallStack() *CallStack {
	result := new(CallStack)
	return result
}
func (this *CallStack) Push(ob *DrFuncCall) {
	this.slice = append(this.slice, ob)
}
func (this *CallStack) Pop() *DrFuncCall {
	n := len(this.slice)
	result := this.slice[n-1]
	this.slice = this.slice[:n-1]
	return result
}
func (this *CallStack) Len() int {
	return len(this.slice)
}
func (this *CallStack) Last() *DrFuncCall {
	return this.slice[this.Len()-1]
}
func (this *CallStack) IsEmpty() bool {
	if len(this.slice) == 0 {
		return true
	} else {
		return false
	}
}
